<template>
    <view class="giantScreen" :style="{'padding-top':`${clientRect.allHeight}px`}">
        <div class="bg background--custom"></div>
        <div class="body">
            <div class="left">
                <div class="sherep" @click="sherep_handleClick">
                    <div class="icon">
                        <image class="img" mode="widthFix" src="/static/img/agent/sherep.svg"></image>
                    </div>
                    <span class="text">شەرەپ تاختىسى</span>
                </div>
            </div>
            <div class="right">
                <div class="userinfo">
                    <view class="user">
                        <div class="name">{{userInfo.username||'name'}}</div>
                        <view class="id">UID:{{userInfo.id}}</view>
                    </view>
                    <view class="avatar">
                        <image class="img" :src="userInfo.useravatar"></image>
                    </view>
                </div>
            </div>
        </div>
        <div class="foot">
            <div class="list">
                <div class='item'>
                    <div class='price'>¥{{pulum.qalduq}}</div>
                    <div class="text">قالدۇق</div>
                </div>
                <div class='item'>
                    <div class='price'>¥{{pulum.tamam}}</div>
                    <div class="text">نەقلەشتۈرگىنىم</div>
                </div>
                <div class='item'>
                    <div class='price'>¥{{pulum.jemi}}</div>
                    <div class="text">بارلىق تاپقىنىم</div>
                </div>
            </div>
            <view @click="neqlesh" class="btn">نەقلەشتۈرۈش</view>
        </div>
    </view>
</template>

<script>
    import {
        navigateBack
    } from '@/scripts/compatible/pageOptions.js'
    import {
        allHeight
    } from '@/scripts/compatible/clientRect.js'
    import {
        neqleshturush
    } from '@/api/agent.js'
    export default {
        props: {
            userInfo: {
                type: Object,
                require: true
            },
            pulum: {
                type: Object,
                require: true
            },
        },
        data() {
            return {
                clientRect: {
                    height: 32,
                    top: 24,
                    right: 8,
                },
            }
        },
        mounted() {
            this.clientRect_init()
        },
        methods: {
            async neqlesh() {
                const res = await neqleshturush()
                if (res) {
                    this.$emit('handleRefresh')
                } else {
                    uni.showToast({
                        title: '请求失败',
                        icon: 'error'
                    })
                }
            },
            sherep_handleClick() {
                uni.navigateTo({
                    url: '/pages/sherep/index'
                })
            },
            clientRect_init() {
                this.clientRect = {
                    allHeight
                }
            },
            handleBack() {
                navigateBack()
            },
            handleHome() {
                uni.reLaunch({
                    url: '/pages/index/index'
                })
            },
        },
    }
</script>

<style lang="scss" scoped>
    .giantScreen {
        position: relative;
        height: 400px;
        box-sizing: border-box;
        border-bottom-right-radius: 10%;
        border-bottom-left-radius: 10%;
        overflow: hidden;

        .bg {
            position: absolute;
            z-index: -1;
            top: 0;
            width: 150%;
            left: -25%;
            height: 300px;
            border-radius: 0 0 50% 50%;
        }

        .body {
            overflow: hidden;
            padding: 20px 20px 15px;
            display: flex;
            align-items: center;
            justify-content: space-between;

            .sherep {
                background-color: #fff;
                height: 36px;
                border-radius: 18px;
                padding: 0 10px;
                color: #333;
                display: flex;
                align-items: center;
                flex-direction: row-reverse;

                .icon {
                    width: 22px;
                    margin-left: 10px;

                    .img {
                        display: block;
                        width: 100%;
                    }
                }

                .text {
                    direction: rtl;
                    font-size: 12px;
                }
            }

            .userinfo {
                display: flex;
                align-items: center;

                .avatar {
                    width: 50px;
                    height: 50px;
                    margin: 0 auto;
                    background-color: rgba(0, 0, 0, .2);
                    position: relative;
                    // box-shadow: #ffffff6e 0 0 0 10rpx;
                    border: 5px solid #ffffff6e;
                    border-radius: 50%;
                    overflow: hidden;

                    .img {
                        display: block;
                        width: 100%;
                        height: 100%;
                    }
                }

                .user {
                    width: max-content;
                    height: max-content;
                    color: #fff;
                    margin-right: 10px;

                    .name {
                        color: #fff;
                        text-align: right;
                        margin-bottom: 5px;
                    }

                    .id {
                        color: #fff;
                        font-size: 12px;
                    }
                }
            }


        }

        .foot {
            position: absolute;
            height: 130px;
            bottom: 40px;
            left: 20px;
            right: 20px;
            background-color: #fff;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 0 14px -14rpx #73849c97;
            padding-top: 15px;
            box-sizing: border-box;

            .list {
                height: 45px;
                display: flex;

                .item {
                    height: 45px;
                    flex: 1;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    font-size: 12px;

                    .price {
                        color: #2b87ff;
                    }

                    .text {
                        color: #999;
                        margin-top: 4px;
                    }
                }
            }

            .btn {
                overflow: hidden;
                text-align: center;
                background-image: linear-gradient(90deg, #0aece7 0%, #5885fb 100%);
                color: #fff;
                height: 80rpx;
                line-height: 76rpx;
                border-radius: 80rpx;
                margin: 30rpx 40rpx 0;
            }
        }
    }
</style>